<template>
	<view>
		<scroll-view scroll-y="true" @scrolltolower="loadMore" :style="'height:' + scrollH + 'px;'">
			<view class="d-flex flex-column">
				<!-- 加载中 -->
				<template>
					<!-- <view v-show="isShowLoading" class="" :style="'height:' + scrollH + 'px;'">
						<image src="../../../static/images/loading.gif" style="height: 750upx;width: 750upx;"></image>
					</view> -->
					<view v-show="isShowLoading" class="" :style="'height:' + scrollH + 'px;'">
						<view class="d-flex a-center j-center" style="height: 600upx;">
							<image src="../../../static/images/loading1.gif" style="height: 75upx;width: 75upx;"></image>
						</view>
					</view>
				</template>
				<view v-show="!isShowLoading" v-for="(item, idx) in mainContentList" :key="idx">
					<!-- 横向房价滚动栏 -->
					<template v-if="item.module === 'lpxq' && item.list.length > 0">
						<house-slide :dataList="item.list"></house-slide>
					</template>
					<!-- 新闻推荐位 -->
					<template v-if="item.module === 'xwtjw' && item.list.length > 0">
						<news-list-module :newsList="item.list"></news-list-module>
					</template>
					<!-- PDF下载 -->
					<template v-if="item.module === 'pdf'">
						<load-module></load-module>
					</template>
					<!-- 推荐位 -->
					<template v-if="item.module === 'tjw' && item.list.length > 0">
						<!-- 专题 -->
						<subject-module v-if="item.list[0].type === 'SPECIAL'" :content="item.list[0]"></subject-module>
						<!-- 广告 -->
						<poster-module v-if="item.list[0].type === 'ADVERTISEMENT'"></poster-module>
					</template>
					<!-- 新闻视频 -->
					<template v-if="item.moduleType === 'xwsp' && item.list.length > 0">
						<video-item :item="item.list[0]"></video-item>
					</template>
					<!-- 轮播广告 -->
					<template v-if="item.moduleType === 'gg' && item.list.length > 0">
						<swiper-adver :dataList="item.list"></swiper-adver>
					</template>
					<!-- 专题 -->
					<template v-if="item.moduleType === 'zt' && item.list.length > 0">
						<subject-module :content="item.list[0]"></subject-module>
					</template>
					<!-- 一般栏目 -->
					<sun-divider v-if="item.moduleType === 'channel' && item.list.length > 0"></sun-divider>
					<template v-if="item.moduleType === 'channel' && item.list.length > 0">
						<column-block :dataObj="item"></column-block>
					</template>
					<!-- 问吧栏目 -->
					<sun-divider v-if="item.moduleType === 'wb' && item.list.length > 0"></sun-divider>
					<template v-if="item.moduleType === 'wb' && item.list.length > 0">
						<question-block :dataObj="item.list[0]"></question-block>
					</template>
					<!-- 专家评楼 -->
					<sun-divider v-if="item.moduleType === 'zjpl'"></sun-divider>
					<template v-if="item.moduleType === 'zjpl'">
						<export-block :dataObj="item"></export-block>
					</template>
					<!-- 以下为无限下拉板式 -->
					<template v-if="item.type === 'BAR'">
						<question-block :dataObj="item"></question-block>
					</template>
					<template v-if="item.type === 'SMALL_IMAGE_CONTENT'">
						<news-item :isSingle="true" :item="item"></news-item>
					</template>
					<template v-if="item.type === 'BIG_IMAGE_CONTENT'">
						<news-item-big :isSingle="true" :item="item"></news-item-big>
					</template>
					<template v-if="item.type === 'SMALL_IMAGE_POSITION'">
						<news-item :isSingle="true" :item="item" :isRecommend="true"></news-item>
					</template>
					<template v-if="item.type === 'BIG_IMAGE_POSITION'">
						<news-item-big :isSingle="true" :item="item" :isRecommend="true"></news-item-big>
					</template>
				</view>
				<sun-divider></sun-divider>
				<!-- 加载更多 -->
				<view class="d-flex a-center j-center font-md py-2">{{ currentLoadText }}</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import newsItem from '@/components/module/news-item.vue';
	import newsItemBig from '@/components/module/news-item-big.vue';
	import sunDivider from '@/components/common/sun-divider.vue';
	import cardItem from '@/components/module/card-item.vue';
	import newsListModule from '@/components/module/news-list-module.vue';
	import posterModule from '@/components/module/poster-module.vue';
	import subjectModule from '@/components/module/subject-module.vue';
	import videoItem from '@/components/module/video-item.vue';
	import loadModule from '@/components/module/load-module.vue';
	import swiperAdver from '@/components/common/swiper-adver.vue';
	import columnBlock from '../templates/column-block.vue';
	import houseSlide from '@/components/module/house-slide.vue';
	import questionBlock from '../templates/question-block.vue';
	import exportBlock from '../templates/export-block.vue';
	import api from '@/common/lib/request.js';
	export default {
		data() {
			return {
				tankType: 1,
				scrollH: 600,
				mainContentList: [],
				isShowLoading: false,
				currentSite: 1,
				currentPageNo: 1,
				currentLoadText: '上拉加载更多',
				loadStatus: ['上拉加载更多', '加载中', '没有更多了']
			};
		},
		components: {
			newsItem,
			newsItemBig,
			sunDivider,
			cardItem,
			newsListModule,
			posterModule,
			subjectModule,
			loadModule,
			videoItem,
			swiperAdver,
			columnBlock,
			houseSlide,
			questionBlock,
			exportBlock
		},
		onLoad(options) {
			this.tankType = options.type;
			if(options.type == 5){
				location.href ="http://www.creb.com.cn/special/zkzb/index.html"
			}
			uni.setNavigationBarTitle({
				'title': options.title
			})
			uni.getSystemInfo({
				success: res => {
					this.scrollH = res.windowHeight;
				}
			});
			this.__initChildWarehouseSource(1)
		},
		methods: {
			__initChildWarehouseSource(pageNo) {
				const _this = this;
				if (pageNo === 1) {
					this.isShowLoading = true;
				}
				api.request({
						url: '/channel/zfzk/child/contents',
						data: {
							page: pageNo,
							siteId: this.currentSite,
							type: this.tankType
						}
					})
					.then(response => {
						console.log(response);
						if (response.length > 0) {
							_this.mainContentList = [..._this.mainContentList, ...response];
							_this.currentPageNo++;
							_this.currentLoadText = _this.loadStatus[0];
							_this.isShowLoading = false;
						} else {
							_this.currentLoadText = _this.loadStatus[2];
						}
					})
					.catch(err => {
						console.log(err);
					});
			},
			loadMore() {
				if (this.currentLoadText !== '上拉加载更多') {
					return;
				}
				this.currentLoadText = this.loadStatus[1];
				this.__initChildWarehouseSource(this.currentPageNo);
			},
			loadWebPage(type){
				
			}
		}
	}
</script>

<style lang="scss">

</style>
